package com.example.cloud.service.business.medical.impl;

import com.example.cloud.dao.business.medical.SkinDiagnosis;
import com.example.cloud.dao.business.medical.SkinDiagnosisRepository;
import com.example.cloud.service.business.medical.SkinDiagnosisService;
import com.example.cloud.utils.BusinessUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

/**
 * Created by wangtao on 2018/6/6.
 */
@Service
public class SkinDiagnosisServiceImpl implements SkinDiagnosisService {

    private static final Logger logger = Logger.getLogger(SkinDiagnosisServiceImpl.class);

    @PersistenceContext
    EntityManager em;

    @Autowired
    private SkinDiagnosisRepository skinDiagnosisRepository;

    @Override
    public SkinDiagnosis findOne(Long id) {
        return skinDiagnosisRepository.findOne(id);
    }

    @Override
    @Transactional
    public SkinDiagnosis doSave(SkinDiagnosis record) {
        BusinessUtil.appendRecord(record);
        return skinDiagnosisRepository.save(record);
    }

    @Override
    @Transactional
    public void doDelete(List<Long> ids) {
        skinDiagnosisRepository.deleteByIdIn(ids);
    }
}
